#!/bin/sh
# search for dsp and save the output with time and group information into text file
# usage: bash dsps.sh m n
# where the orders of the small groups are between m and n
# see https://gap-packages.github.io/smallgrp/doc/chap0_mj.html#contents for more details.

/home/eric/app/gap/gap-4.12.2/gap -q -o 32g << EOI
LoadPackage("dsp");;
for order in [$1..$2] do
	for idx in [1..NumberSmallGroups(order)] do
		G := SmallGroup(order, idx);;
		if not IsAbelian(G) then
			continue;;
		fi;;
		output := DifferenceSetPairs(G);;
		t := StringTime(time);;
		len := Length(output);;
		f := "";;
		outputStringStream := OutputTextString(f, true);;
		PrintTo(outputStringStream, order, "-", idx, ".txt");;
		CloseStream(outputStringStream);;
		PrintTo(f, "## Group: [", order,", ", idx,"]\n## Difference Set Pairs: ", len, "\n## Time: ", t, "\n\n");;
		AppendTo(f, "return [\n");;
		for i in [1..Length(output)] do
			AppendTo(f, output[i]);;
			if i < Length(output) then AppendTo(f, ",");; fi;;
			AppendTo(f, "\n");;
		od;;
		AppendTo(f, "];\n\n");;
	od;;
od;;
EOI

